Skip to content

add test for loading and unloading ICDs (cl_khr_icd_unloadable)#2621

Open
bashbaug wants to merge 5 commits intoKhronosGroup:mainfrom
bashbaug:cl_khr_icd_unloadable
Open

add test for loading and unloading ICDs (cl_khr_icd_unloadable)#2621
bashbaug wants to merge 5 commits intoKhronosGroup:mainfrom
bashbaug:cl_khr_icd_unloadable

Conversation

@bashbaug
Copy link
Copy Markdown
Contributor

This PR adds a CTS test for the cl_khr_icd_unloadable extension, see:

The CTS test follows a similar methodology as the ICD loader unit test:

  1. The test is primarily implemented in a dynamic library "plugin".
    • The "plugin" links with the harness (and hence the OpenCL ICD loader) and makes OpenCL API calls.
    • The "plugin" currently runs a single test, which creates a kernel, executes it, checks the results, and cleans up.
  2. The test executable is responsible for dynamically loading the "plugin" and invoking it to execute the test.
    • The test executable does NOT link with the harness or the OpenCL ICD loader and does not directly make any OpenCL API calls.
    • If the test executable is able to load the plugin, run the test, and unload the plugin N times (where N is currently 5), the overall test is considered to pass, and the test executable returns "success". Otherwise, the test executable returns "failure".

@bashbaug
Copy link
Copy Markdown
Contributor Author

For now, I am mostly interested in the high-level approach. Is this something we would consider appropriate for a CTS test? Is there a lighter-weight way to test these changes?

Of course, if the high-level approach looks OK, I would be interested in detailed comments also. Thanks!

@bashbaug
Copy link
Copy Markdown
Contributor Author

Note, if anybody wants to build and run this test, I was not seeing the intended unloading behavior when I compiled the tests with gcc. Specifically, the call to dlclose did not seem to close the dynamic library "plugin". I haven't fully identified why this is happening, but I suspect it is due to:

https://stackoverflow.com/questions/78603238/reloading-a-dynamically-loaded-library-with-dlclose-dlopen-works-with-clang-on

This doesn't cause any sort of test failure, but it also limits what the test is testing. When I compiled the test with Clang I saw the intended unloading behavior.

I haven't tried any compilation on Windows just yet.

@Kerilk
Copy link
Copy Markdown

Kerilk commented Mar 16, 2026

It would be interesting to understand why it happens here and not in the loader test where I verified the behavior, at least on linux.

Aside from that, the test looks good to me.

@bashbaug
Copy link
Copy Markdown
Contributor Author

Discussed in the March 17th teleconference.

We're going to try to figure out why the unloading isn't happening for gcc before merging.

We're also going to do some testing on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants